# Maintainer:
# Contributor: Donald Webster <fryfrog@gmail.com>

pkgname=python-attrdict
_name=${pkgname#python-}
pkgver=2.0.1
pkgrel=6
pkgdesc='A library that provides mapping objects that allow their elements to be accessed both as keys and as attributes'
arch=(any)
url='https://pypi.org/project/attrdict/'
license=(MIT)
depends=(python)
makedepends=(python-build python-installer python-setuptools python-wheel)
source=("https://files.pythonhosted.org/packages/source/${_name::1}/${_name}/${_name}-${pkgver}.tar.gz")
sha256sums=('35c90698b55c683946091177177a9e9c0713a0860f0e049febd72649ccd77b70')

prepare() {
  cd $_name-$pkgver
# Fix for python 3.10
  find . -type f -iname '*.py' -exec sed -i 's/collections/collections.abc/g' {} +
}

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm644 LICENSE.txt -t "$pkgdir"/usr/share/licenses/$pkgname
}
